package grape.composite.service.activity.api;

import grape.composite.service.activity.po.ActivityContent;
import grape.common.service.common.IBaseService;

/**
 * <p>
 * 活动内容表 服务类
 * </p>
 *
 * @author yangwei
 * @since 2020-08-25
 */
public interface IActivityContentService extends IBaseService<ActivityContent> {

    /**
     * 根据活动id删除
     * @param activityId 必填
     * @return
     */
    default boolean removeByActivityId(String activityId) {
        assertParamNotEmpty(activityId,"activityId不能为空");
        ActivityContent activityContent = new ActivityContent();
        activityContent.setActivityId(activityId);
        return remove(activityContent);
    }

    /**
     * 根据活动id查询
     * @param activityId 必填
     * @return
     */
    default ActivityContent getByActivityId(String activityId) {
        assertParamNotEmpty(activityId,"activityId不能为空");
        ActivityContent activityContent = new ActivityContent();
        activityContent.setActivityId(activityId);
        return getOne(activityContent);
    }

    /**
     * 根据活动id更新内容
     * @param activityId
     * @param content
     * @return
     */
    default boolean updateByActivityId(String activityId, String content) {

        ActivityContent byActivityId = getByActivityId(activityId);

        ActivityContent activityContent = new ActivityContent();
        activityContent.setId(byActivityId.getId());
        activityContent.setContent(content);
        return updateById(activityContent);
    }
}
